package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.ShoppingCartDetailDO;
import com.starlink.model.request.ShoppingCartDetailRequest;
import com.starlink.model.vo.ShoppingCartDetailVO;
import com.starlink.model.vo.book.CartSpecificationVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author zhanghong
 */
@Repository
public interface ShoppingCartDetailMapper extends BaseMapper<ShoppingCartDetailDO> {
    ShoppingCartDetailDO selectDOById(Long id);
    List<ShoppingCartDetailDO> selectDOList(ShoppingCartDetailDO shoppingCartDetail);
    int insertDO(ShoppingCartDetailDO shoppingCartDetail);
    int batchInsertDO(List<ShoppingCartDetailDO> shoppingCartDetailDOList);
    int updateDO(ShoppingCartDetailDO shoppingCartDetail);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from shopping_cart_detail",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") ShoppingCartDetailRequest param);

    List<ShoppingCartDetailVO> pageQuery(@Param("param") ShoppingCartDetailRequest param, @Param("limit") int limit, @Param("offset") long offset);

    Map<String,Long> getCountByUserId(@Param("userId") long userId);

    List<ShoppingCartDetailVO> selectListDo(@Param("carId")Long carId);

    void batchDeleted(@Param("list") List<Long> orderCarProductIds);

    List<CartSpecificationVO> selectCartSpecificationList(@Param("carId")Long carId);

    void updateByParam(@Param("carId")Long carId, @Param("list")List<Long> articlesIdList);

    ShoppingCartDetailDO selectIsNotHave(ShoppingCartDetailDO shoppingCartDetailDO);
}
